// 动态创建模块

import { ConfigurableModuleBuilder } from '@nestjs/common';

interface PersonModuleOptions {
  name: string;
  age: number;
}

export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE } =
  new ConfigurableModuleBuilder<PersonModuleOptions>()
    .setClassMethodName('forRoot')
    .setExtras(
      {
        isGlobal: true, // 全局注册
      },
      (definition, extras) => ({ ...definition, isGlobal: extras.isGlobal }),
    )
    .build();
